import { createStore } from 'vuex'

export default createStore({
    state: {
        depCode: '36%',
        isLoading: null,
        selectValue: "",
		token:"",
    },
    mutations: {
        // 定义mutations，用于修改状态(同步)
        updateDepCode(state, depCode) {
            state.depCode = depCode
        },
        setLoading(state, isLoading) {
            state.isLoading = isLoading;
        },
        changeSelectValue(state, depCode) {
            state.selectValue = depCode
        },
		
		 setToken(state, token) {
		      state.token = token
		    },
		    clearToken(state) {
		      state.token = null
		    }
    },
    actions: {
        // 定义actions，用于修改状态(异步)
        updateDepCode(context, depCode) {
            context.commit('updateDepCode', depCode)
        },
        onLoading(context, isLoading) {
            context.commit('setLoading', isLoading);
        },
        changeSelectValue(context, depCode) {
            context.commit('changeSelectValue', depCode);
        },
		setToken(context,token){
			 context.commit('setToken',token);
		},
		clearToken(context){
			 context.commit('clearToken');
		}
    },
    getters: {
		 getToken: state => {
		    return state.token
		  }

    },
    modules: {
    }
})